<?php defined('SYSPATH') or die('No direct access allowed.');

class Model_Fenxiao_Config extends ORM {

    public static function get_val($varname,$groupid = 0)
    {
        $query =DB::select()->from('fenxiao_config')->where('varname','=',$varname);
        if(!empty($groupid))
        {
            $query->and_where('groupid', '=', $groupid);
        }

        if($groupid===0 || $groupid==='0')
        {
            $query->where_open();
            $query->and_where('groupid', '=', 0);
            $query->or_where('groupid','=',null);
            $query->where_close();
        }


        $info=$query->execute()->current();
        if(!$info)
            return null;
        else
            return $info['value'];
    }
}